package models;

import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import play.db.jpa.Model;

@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@Entity
public abstract class Producto extends Model {
	
	public int cantidad;
	public float ancho;
	public float largo;
	@ManyToOne
	@Cascade(CascadeType.DELETE)
	@JoinColumn(name="idImpresion")
	public Tarea impresion;
	@ManyToOne
	@JoinColumn(name="idCalidad")
	public Calidad calidad;

	protected float calcularPrecioBase(){
		return  ancho * largo * ((Impresion)impresion).materialImpresion.precio * (1 + calidad.incremento / 100);
	}
	
	public abstract float calcularPrecio();
}
